<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>数组转化为字符串</title>
</head>
<body>
	<h1>数组转化为字符串</h1><hr>
	<script type="text/javascript">
		var myArr = new Array();
		for(var i=0; i<10; i++) {
			myArr[i] = i*i;
		}
		
		document.write("<br><br>myArray的类型为: " + typeof(myArr));
		document.write("<br>myArray的内容为: ");
		for(var i=0; i<myArr.length; i++) {
			document.write(myArr[i] + " ");
		}
		
		//转化为字符串,默认分隔符为逗号,
		Str1 = myArr.join();
		document.write("<br><br>myArray的类型为: " + typeof(Str1));
		document.write("<br>myArray的内容为: " + Str1);
		
		//转化为字符串,分隔符为分号:
		Str2 = myArr.join(":");
		document.write("<br><br>myArray的类型为: " + typeof(Str2));
		document.write("<br>myArray的内容为: " + Str2);
			
	</script>
</body>
</html>